package hubol;

import java.io.IOException;

import com.jogamp.opengl.GLException;

import bogus.core.BogusCore;
import audio.Clip;
import owg.util.Calc;
import owg.util.ClassPathStream;
import owg.util.NamedInputStream;
import owg.util.opengl.EGL3;
import owg.util.opengl.ShaderLib;
import owg.util.opengl.ShaderProgram;

public class Hubol {
	public static void playPitched(Clip sound){
		playPitched(sound, .1);
	}
	
	public static void playPitched(Clip sound, double random){
		sound.setSpeed(null, 1 + Calc.rangedRandom(random));
		sound.play();
	}
	
	public static ShaderProgram loadProgram(NamedInputStream vertexFile, NamedInputStream fragmentFile){
		try {
			if (vertexFile == null)
				vertexFile = new ClassPathStream(EGL3.class, "owg/util/opengl/shaders/default.vert");
			if (fragmentFile == null)
				fragmentFile = new ClassPathStream(EGL3.class, "owg/util/opengl/shaders/default.frag");
			return ShaderLib.get(BogusCore.egl, vertexFile, fragmentFile);
		} catch (GLException | IOException e) {
			throw new RuntimeException(e);
		}
	}
}
